package com.wayne.mapper;

import com.wayne.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IRoleMapper {
  @Insert("insert into t_role values(#{id},#{roleName},#{roleDesc})")
  int insert(Role role);

  @Update("update t_role set role_name = #{roleName},role_desc=#{roleDesc} where id = #{id}")
  int update(Role role);

  @Delete("delete from t_role where id = #{id}")
  int delete(int id);

  @Select("select * from t_role where id = #{id}")
  Role findById(int id);

  @Select("select * from t_role")
  List<Role> findAll();

  @Select("select r.* from t_role r,t_user_role ur where ur.role_id = r.id and ur.user_id = #{id}")
  List<Role> findByUid(int id);
}
